package com.gxgeek.springweb.filter.encrypt;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author gaoxing
 * @create 2018-08-30 下午2:54
 */
public class EncryptFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        if (request.getRequestURI().contains("v3/tasks") ) {
            filterChain.doFilter(new EncryptHttpServletRequestWrapper(request,null), response);
        } else {
            filterChain.doFilter(request, response);
        }

    }

    @Override
    public void destroy() {
    }



}
